package com.jrowny.mediators
{
	import com.jrowny.proxy.FileProxy;
	
	import components.Preferences;
	
	import flash.events.Event;
	
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class PreferencesMediator extends Mediator
	{
		public static const NAME:String = "PreferencesMediator";
		private var fileProxy:FileProxy;
		public function PreferencesMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);
			preferences.addEventListener(Preferences.EVENT_CHANGE_SPRITE_SELECTOR,onChangeSpriteSelector);
			preferences.addEventListener(Preferences.EVENT_TOGGLE_MINIFY,onToggleMinify);
			fileProxy = facade.retrieveProxy(FileProxy.NAME) as FileProxy;
		}
		public function get preferences():Preferences{
			return viewComponent as Preferences;
		}
		
		public function onChangeSpriteSelector(event:Event):void{
			fileProxy.spriteSelector = preferences.spriteSelector.text;
		}
		public function onToggleMinify(event:Event):void{
			fileProxy.minify = !fileProxy.minify;
		}
		
	}
}